import { trigger } from "../effect/trigger";
import { TriggerOpTypes } from "../utils";

export default function deleteHandler(target: any, key: string | symbol) {
  const hasKey = Reflect.has(target, key);
  const res = Reflect.deleteProperty(target, key);
  if (hasKey && res) { 
    trigger(target, TriggerOpTypes.DELETE, key);
  }
  return res;
}